#pragma once

#include <cftf/net/tcpsession.h>

class GGSession : public cftf::net::TcpSession
{
public:
	GGSession(cftf::net::TcpListener* listener, int socket_handle, boost::asio::ip::tcp::socket socket, std::size_t max_packet_len);

    unsigned int GetSpeed() const { return seed_; }
    void SetKey(const unsigned char* data, std::size_t len);

protected:

	virtual bool DecodePacket(boost::beast::flat_buffer& buff, bool& stop) override;

    void DecryptRecv(unsigned char* data, size_t len);
    virtual void EncryptSend(unsigned char* data, size_t len) override;

private:
    unsigned int seed_ = 0;
    std::vector<unsigned char> key_;
    unsigned char send_i_ = 0;
    unsigned char send_j_ = 0;
    unsigned char recv_i_ = 0;
    unsigned char recv_j_ = 0;
    bool initialized_ = false;
};
